package com.yun.util.yun.leetCode.simple;

import java.util.Arrays;

/**
 * 整数之和
 */
public class TwoSum {
    public int[] twoSum(int[] nums, int target) {
        return twoSum1(nums,target,0,new int[10000]);
    }

    private int[] twoSum1(int[] nums, int target, int count, int[] ints) {
        for (int i = 1; i < nums.length; i++) {
            if (target-nums[0]==nums[i]){
                return new int[]{count, count+i};
            }
            ints[i-1] = nums[i];
        }
        return twoSum1(ints,target,count+1,new int[10000]);
    }


    public static void main(String[] args) {
        TwoSum solution = new TwoSum();
        int[] a = {4,1,8};
        int b = 9;
        int[] ints = solution.twoSum(a, b);
        System.out.println(Arrays.toString(ints));
    }

}
